package com.architecture.core.except;

import com.architecture.core.utils.ErrCode;
import com.architecture.core.utils.ErrConfig;
import org.apache.commons.lang.StringUtils;

/**
 * <p>Project: BTC</p>
 * <p>Description: </p>
 * <p>Copyright (c) 2012 Wilmar Consultancy Services</p>
 * <p>All Rights Reserved.</p>
 *
 * @author <a href="mailto:hujianguang@wcs-global.com">胡建光</a>
 */
public class ErrException extends Exception {

    private String errCode;

    public ErrException(String errCode) {
        this.errCode = errCode;
    }

    public String getErrCode() {
        if (StringUtils.isNumeric(this.errCode)) {
            return errCode;
        } else {
            return ErrCode.ERROR_CODE;
        }
    }

    @Override
    public String getMessage() {
        return ErrConfig.getCode(errCode);
    }

    @Override
    public String toString() {
        return ErrConfig.getCode(errCode);
    }
}
